/*    */ package com.zimbra.cs.service.mail;
/*    */ 
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.MailConstants;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.accesscontrol.ACLUtil;
/*    */ import com.zimbra.cs.account.accesscontrol.Right;
/*    */ import com.zimbra.cs.account.accesscontrol.RightManager;
/*    */ import com.zimbra.cs.account.accesscontrol.ZimbraACE;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.HashSet;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ import java.util.Set;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class GetPermission
/*    */   extends MailDocumentHandler
/*    */ {
/*    */   public Element handle(Element request, Map<String, Object> context)
/*    */     throws ServiceException
/*    */   {
/* 42 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 43 */     Account account = getRequestedAccount(zsc);
/*    */     
/* 45 */     if (!canAccessAccount(zsc, account)) {
/* 46 */       throw ServiceException.PERM_DENIED("can not access account");
/*    */     }
/* 48 */     Set<Right> specificRights = null;
/* 49 */     for (Element eACE : request.listElements("ace")) {
/* 50 */       if (specificRights == null)
/* 51 */         specificRights = new HashSet();
/* 52 */       specificRights.add(RightManager.getInstance().getUserRight(eACE.getAttribute("right")));
/*    */     }
/*    */     
/* 55 */     List<ZimbraACE> aces = specificRights == null ? ACLUtil.getAllACEs(account) : ACLUtil.getACEs(account, specificRights);
/* 56 */     Element response = zsc.createElement(MailConstants.GET_PERMISSION_RESPONSE);
/* 57 */     if (aces != null) {
/* 58 */       for (ZimbraACE ace : aces)
/* 59 */         ToXML.encodeACE(response, ace);
/*    */     }
/* 61 */     return response;
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/mail/GetPermission.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */